package fr.afcepf.atod18.entity;

import java.util.Calendar;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

//Annotations
@Entity
@Table
public class Promotion {
	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private int id;
	@Temporal(TemporalType.DATE)
	private Calendar dateDebut;
	@Temporal(TemporalType.DATE)
	private Calendar dateFin;
	private int offre;
	
	@OneToMany(cascade= CascadeType.MERGE)
	@JoinTable(joinColumns={@JoinColumn(name="promotion_id")}, inverseJoinColumns={@JoinColumn(name="produit_id")})
	private Set<Produit> produits;
	
	public Set<Produit> getProduits() {
		return produits;
	}
	public void setProduits(Set<Produit> produits) {
		this.produits = produits;
	}
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public int getOffre() {
		return offre;
	}
	public void setOffre(int offre) {
		this.offre = offre;
	}
	public Calendar getDateDebut() {
		return dateDebut;
	}
	public void setDateDebut(Calendar dateDebut) {
		this.dateDebut = dateDebut;
	}
	public Calendar getDateFin() {
		return dateFin;
	}
	public void setDateFin(Calendar dateFin) {
		this.dateFin = dateFin;
	}

}
